package com.ncp.servlet.cart;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HandleCartServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html");
		this.checkIsLogin(request, response);
	}
	
	public void checkIsLogin(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException {
		PrintWriter out = response.getWriter();
	//	System.out.println(request.getSession().getAttribute("cart"));
		String userLoginName = (String)request.getSession().getAttribute("LoginName");
		System.out.println("LoginName = "+userLoginName);
		if("".equals(userLoginName)||userLoginName==null){
			out.print("<script language=javascript>alert('请登录！');window.location.replace('index.jsp');</script>"); 
		}else{
			request.getRequestDispatcher("pages/cart/confirmorder.jsp").forward(request, response);
		}
	}

}
